﻿Public Class KBanner : Inherits UserControl

    Public PART_Icon As Image
    Public PART_Body As GripLabel
    Public PART_LeftButton As KButton
    Public PART_MiddleButton As KButton
    Public PART_RightButton As KButton



    Public Property IsActivated As Boolean
        Get
            Return GetValue(IsActivatedProperty)
        End Get

        Set(ByVal value As Boolean)
            SetValue(IsActivatedProperty, value)
        End Set
    End Property

    Public Shared ReadOnly IsActivatedProperty As DependencyProperty = _
                           DependencyProperty.Register("IsActivated", _
                           GetType(Boolean), GetType(KBanner), _
                           New FrameworkPropertyMetadata())     'Non sembra possibile impostare uno stile che abbia una dep prop come target se ha già definito un valore di default o impostato in xaml.


    Public Sub New()


        Dim g As New Grid

        g.ColumnDefinitions.Add(New ColumnDefinition With {.Width = GridLength.Auto})
        g.ColumnDefinitions.Add(New ColumnDefinition With {.Width = New GridLength(1, GridUnitType.Star)})
        g.ColumnDefinitions.Add(New ColumnDefinition With {.Width = GridLength.Auto})
        g.ColumnDefinitions.Add(New ColumnDefinition With {.Width = GridLength.Auto})
        g.ColumnDefinitions.Add(New ColumnDefinition With {.Width = GridLength.Auto})

        g.Background = Brushes.Transparent


        PART_Icon = New Image
        PART_Icon.HorizontalAlignment = Windows.HorizontalAlignment.Center
        PART_Icon.Stretch = Stretch.Fill
        PART_Icon.VerticalAlignment = Windows.VerticalAlignment.Center
        PART_Icon.Margin = New Thickness(2)
        Grid.SetColumn(PART_Icon, 0)

        PART_Body = New GripLabel
        PART_Body.Content = ""
        PART_Body.VerticalContentAlignment = Windows.VerticalAlignment.Center
        PART_Body.VerticalAlignment = Windows.VerticalAlignment.Stretch
        PART_Body.HorizontalAlignment = Windows.HorizontalAlignment.Stretch
        PART_Body.Padding = New Thickness(6, 0, 6, 0)
        ' PART_Body.Background = Nothing
        Grid.SetColumn(PART_Body, 1)

        ' Foreground = Brushes.Black

        PART_RightButton = New KButton
        PART_RightButton.HorizontalAlignment = Windows.HorizontalAlignment.Center
        PART_RightButton.VerticalAlignment = Windows.VerticalAlignment.Center
        ' PART_RightButton.Width = 12
        ' PART_RightButton.Height = 12
        Grid.SetColumn(PART_RightButton, 4)
        PART_RightButton.Margin = New Thickness(2)
        ' PART_RightButton.Background = Brushes.Red

        PART_MiddleButton = New KButton
        PART_MiddleButton.HorizontalAlignment = Windows.HorizontalAlignment.Center
        PART_MiddleButton.VerticalAlignment = Windows.VerticalAlignment.Center
        ' PART_MiddleButton.Width = 12
        '  PART_MiddleButton.Height = 12
        Grid.SetColumn(PART_MiddleButton, 3)
        PART_MiddleButton.Margin = New Thickness(2)
        ' PART_MiddleButton.Background = Brushes.Gold

        PART_LeftButton = New KButton
        PART_LeftButton.HorizontalAlignment = Windows.HorizontalAlignment.Center
        PART_LeftButton.VerticalAlignment = Windows.VerticalAlignment.Center
        ' PART_LeftButton.Width = 12
        ' PART_LeftButton.Height = 12
        Grid.SetColumn(PART_LeftButton, 2)
        PART_LeftButton.Margin = New Thickness(2)
        ' PART_LeftButton.Background = Brushes.LightGreen


        g.Children.Add(PART_Body)
        g.Children.Add(PART_Icon)
        g.Children.Add(PART_LeftButton)
        g.Children.Add(PART_MiddleButton)
        g.Children.Add(PART_RightButton)


        Content = g
    End Sub

    Protected Overrides Sub OnPropertyChanged(ByVal e As System.Windows.DependencyPropertyChangedEventArgs)
        If e.Property Is ForegroundProperty Then
            PART_Body.Foreground = Foreground
        End If
        MyBase.OnPropertyChanged(e)
    End Sub

    Public Sub ToggleIcon()
        PART_Icon.Visibility = 2 - PART_Icon.Visibility         'praticamente passa da Visible a Collapsed.
    End Sub


End Class
